﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using HRM.HRMServiceProxy;


namespace HRM
{
    public partial class frmViewLeaveWork : Form
    {
        int _EmployeeID;
        int _year;
        LeaveWorkClient _wcfLW;

        public frmViewLeaveWork(int EmployeeID, int yearView)
        {
            InitializeComponent();
            _EmployeeID = EmployeeID;
            _wcfLW = Service.LeaveWork();
            _year = yearView;
            LoadData(_EmployeeID, _year);
            Language();
            this.KeyPreview = true;
        }

        public void Language()
        {
            if (this.Tag != null)
                this.Text = UpdateUI.GetString("thongtinngaynghicanhan");
        }

        private void LoadData(int EmployeeID, int _year)
        {
            DataTable dt = _wcfLW.LeaveWork_GetListWithEmployee(EmployeeID, _year).Tables[0];
            dgvLeaveWorkList.DataSource = dt;
            dgvLeaveWorkList.Columns["LW_ID"].Visible = false;
            dgvLeaveWorkList.Columns["LW_EmployeeID"].Visible = false;
            dgvLeaveWorkList.Columns["LW_BranchID"].Visible = false;
            dgvLeaveWorkList.Columns["LW_DepartmentID"].Visible = false;
            dgvLeaveWorkList.Columns["LW_LeaveID"].Visible = false;
            dgvLeaveWorkList.Columns["FullName"].HeaderText = UpdateUI.GetString("hovaten");
            dgvLeaveWorkList.Columns["FullName"].Width = 140;
            dgvLeaveWorkList.Columns["Leave_Name"].HeaderText = UpdateUI.GetString("hinhthucnghi");
            dgvLeaveWorkList.Columns["Leave_Name"].Width = 120;
            dgvLeaveWorkList.Columns["LW_FromDate"].HeaderText = UpdateUI.GetString("tungay");
            dgvLeaveWorkList.Columns["LW_FromDate"].DefaultCellStyle.Format = "dd/MM/yyyy";
            dgvLeaveWorkList.Columns["LW_FromDate"].Width = 80;
            dgvLeaveWorkList.Columns["LW_ToDate"].HeaderText = UpdateUI.GetString("denngay");
            dgvLeaveWorkList.Columns["LW_ToDate"].DefaultCellStyle.Format = "dd/MM/yyyy";
            dgvLeaveWorkList.Columns["LW_ToDate"].Width = 90;
            dgvLeaveWorkList.Columns["LW_TotalDays"].HeaderText = UpdateUI.GetString("tongngaynghi");
            dgvLeaveWorkList.Columns["LW_TotalDays"].Width = 120;            
            dgvLeaveWorkList.Columns["LW_Reason"].HeaderText = UpdateUI.GetString("lydo");
            dgvLeaveWorkList.Columns["LW_Reason"].Width = 200;
        }

        private void frmViewLeaveWork_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.Escape:
                    this.Dispose();
                    this.Close();
                    break;
            }
        }

        private void frmViewLeaveWork_FormClosing(object sender, FormClosingEventArgs e)
        {
            _wcfLW.Close();
        }
    }
}
